package qnb._config;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import qnb.entity.Teacher;
import weixinkeji.vip.expand.poi.JWEOfficeR;


/**
 * 上传Excel文件，存入数据库
 * @author xiaojianzhang
 *
 */
public class ExcelUp {
	public static List<Teacher> readOne(HttpServletRequest req, HttpServletResponse resp,String fileName) throws ServletException, IOException {
		Part part = req.getPart(fileName);
		try {
			List<Teacher> list = null;
			System.out.println(part.getSubmittedFileName());
			if (part.getSubmittedFileName().endsWith(".xls")) {
				//传入需要得到的对象，文件名以及输入流
				list = JWEOfficeR.readExcel_xls(Teacher.class, "教师信息列表", part.getInputStream());
				return list;
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
